// packageAPI/pages/cacheManager/cacheManager.js
var cacheManager = null
Page({
  /**
   * 页面的初始数据
   */
  data: {
    schema: [],
    formData: {
    },
    title: '',
    result: '',
    zh:'',
    apiType: '',
    remark: '',
    webUrl: '',
    apiName: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      apiType: options.zh,
      title: options.title,
      zh: options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    cacheManager = wx.createCacheManager()
    cacheManager.on('enterWeakNetwork',(res)=>{
      this.setData({
        result:res,
        apiName:'CacheManager.on'
      })
    })
  },
  add(){
    let id = cacheManager.addRule('/aaa')
    this.setData({
      result:id,
      apiName:'CacheManager.addRule'
    })
  },
  adds(){
    let id = cacheManager.addRules(['/bbb','/ccc'])
    this.setData({
      result:id,
      apiName:'CacheManager.addRule'
    })
  },
  deleteCache(){
    cacheManager.deleteCache('111')
  },
  deleteCaches(){
    cacheManager.deleteCaches(['111'])
  },
  deleteRule(){
    cacheManager.deleteRule('111')
  },
  deleteRules(){
    cacheManager.deleteRules(['111'])
  },
  clear() {
    cacheManager.clearCaches()
  },
  clearRule(){
    cacheManager.clearRules()
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})